﻿// JavaScript Document
$(document).ready(function() {		   
    $("#mainBottom_ImageButton1").click(function() {
        var mail = document.getElementById('mainBottom_TextSearch').value;
		//var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
        var reg = /^([a-z0-9A-Z]+[-|_|\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-zA-Z]{2,}$/;
        if(!(reg.test(mail))){
            alert("请填写正确的Email。");
            return false;
        }else{
            if(mail.indexOf("'") != -1){
                alert("Email包含非法符号，请纠正。");
                return false;
            }else {
				$.ajax({
					url: "/subscription-email.ac?email="+mail,
					dataType:"html",
					cache:false,
					success: function(responseText){
						if(responseText=="success"){
							alert("您好，您的email["+mail+"]已经订阅成功。");
							$("#mainBottom_TextSearch").val("请输入你的Email");
						}else if(responseText=="exist"){
							alert("您好，您的email["+mail+"]已经订阅过了，请更换Email。");
							$("#mainBottom_TextSearch").val("请输入你的Email");
						}else{ alert("订阅失败。"); }
						
					}
				});
			}
        }
    });
	
	
});		
function Elear(_val){
	var _txt = document.getElementById('mainBottom_TextSearch');
	if(_txt.value == "请输入你的Email")
		_txt.value = "";
	if(_txt.value == "" && _val == 0)
		_txt.value = "请输入你的Email";
}